package algorithm.sort;

public class CharuPaixu {


  public static void main(String[] args) {

    int [] a = new int[]{2,10,6,8,1};
    int left = 0;
    int right = a.length-1;

    for (int i = left, j = i; i < right; j = ++i) {
      int ai = a[i + 1];
      while (ai < a[j]) {
        a[j + 1] = a[j];
        if (j-- == left) {
          break;
        }
      }
      a[j + 1] = ai;
    }

    for (int i : a) {
      System.out.println(i);
    }
  }

}
